package com.hxkj.controller;

import com.hxkj.domain.po.TagsClassify;
import com.hxkj.service.TagsClassifyService;
import com.platform.common.dispatcher.util.ResultStructUtils;
import com.platform.common.domain.result.ParameterDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.result.ResultPageStruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @ClassName TagsClassifyController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/7 11:58
 * @Version 1.0
 */
@RestController
@RequestMapping("/tagsclassify")
public class TagsClassifyController {

    @Autowired
    TagsClassifyService tagsClassifyService;
    /**
     * @author Mr.zheng
     * @Description saveTagsClassify 新增tags标签分类
     * @Date 14:22 2018/6/7
     **/
    @RequestMapping(value = "/save", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> saveTagsClassify(@RequestBody TagsClassify tagsClassify) throws Exception{
        return () -> tagsClassifyService.saveTagsClassify(tagsClassify);
    }

    /**
     * @author Mr.zheng
     * @Description getTagsClassifyList 获取tags标签分类列表
     * @Date 14:22 2018/6/7
     **/
    @RequestMapping(value = "/getlist", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultPageStruct<TagsClassify>> getTagsClassifyList(@RequestBody ParameterDataStruct<TagsClassify> parameterDataStruct) throws Exception{
        return () -> ResultStructUtils.buildResultPageStruct(tagsClassifyService.getTagsClassifyList(parameterDataStruct.getData() == null ?
                new TagsClassify() : parameterDataStruct.getData(), parameterDataStruct.getPageTo()),"param=value");
    }



    /**
     * @author Mr.zheng
     * @Description removerTags 删除tags标签分类
     * @Date 14:23 2018/6/7
     **/
    @RequestMapping(value = "/remove", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> removeTagsClassify(@RequestBody  TagsClassify tagsClassify) throws Exception{
        return () -> tagsClassifyService.removeTagsClassify(tagsClassify);
    }

    /**
     * @author Mr.zheng
     * @Description modifyTags 修改tags标签分类
     * @Date 14:23 2018/6/7
     **/
    @RequestMapping(value = "/modify", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultMessageStruct> modifyTagsClassify(@RequestBody TagsClassify tagsClassify) throws Exception{
        return () -> tagsClassifyService.modifyTagsClassify(tagsClassify);
    }

    /**
     * @author Mr.zheng
     * @Description getTagsList 获取tags标签分类下拉框
     * @Date 14:22 2018/6/7
     **/
    @RequestMapping(value = "/getdownlist", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<List<TagsClassify>> getTagsClassifyDownList(@RequestBody TagsClassify tagsClassify) throws Exception{
        return () -> tagsClassifyService.getTagsClassifyDownList(tagsClassify);
    }
}
